package com.ywb.adapter.classadpter;

import java.awt.event.MouseAdapter;

/**
 * @Author ywb
 * Client
 */
public class Phone {
    public boolean charge(IVoltage5V voltage){
        if(voltage.output() != 5){
            System.out.println("电压等于5V,开始充电");
            return true;
        }

        System.out.println("电压不对，无法充电");
        return false;
    }

    public static void main(String[] args) {
        Phone phone = new Phone();
        System.out.println("===类适配器===");
        phone.charge(new VoltageAdapter5V());
        System.out.println("===对象适配器===");
        phone.charge(new VoltageAdapter(new Voltage220V()));

    }
}
